Import Word document in DOORS, using style

Hi,

i need import a Word document. In this docuemnt, requirements are written in individual tables with 4 cells.
In each cell, specific style is used. For example :

  • RequirementName
  • RequirementText
  • RequirementOrigin
  • RequirementConformity

Normal text have 'Normal" style.

When i import document, word tables are converted in DOORS tables, with paragraph style.

WHO can i have :
  • text with RequirementName, RequirementOrigin and RequirementConformity style in specific attributs
  • text with RequirementText style in Object Text attribut.

Thanks
Pierre Dubarry
PDU - Wed Oct 21 02:17:03 EDT 2009

Re: Import Word document in DOORS, using style
ePiallat - Wed Oct 21 04:47:31 EDT 2009

Hi,

Simplest way is to import normally your document, then run a script that:
  • Detects tables (loop through all objects, and use the "table" function to detect)
  • Checks styles (styles are imported into "Paragraph Style" attribute. If o is a table object, o[1] is its first row, o[1][1] its first cell)
  • Creates a new object after
  • Populates attributes from "object text" of o[1][1] to o[1][4]
  • deletes table (with deleteTable perm, not delete)

Re: Import Word document in DOORS, using style
PDU - Wed Oct 21 07:59:01 EDT 2009

ePiallat - Wed Oct 21 04:47:31 EDT 2009
Hi,

Simplest way is to import normally your document, then run a script that:

  • Detects tables (loop through all objects, and use the "table" function to detect)
  • Checks styles (styles are imported into "Paragraph Style" attribute. If o is a table object, o[1] is its first row, o[1][1] its first cell)
  • Creates a new object after
  • Populates attributes from "object text" of o[1][1] to o[1][4]
  • deletes table (with deleteTable perm, not delete)

Thanks,

but just a "little" problem, i do not find tables !!!

i write this check code :

Module CeModule = current
Object ObjetEnCours

for ObjetEnCours in CeModule do
{
print ObjetEnCours."Absolute Number" " --> " (table ObjetEnCours) "\n"
if (table ObjetEnCours)
{
print "found\r"
continue
}

}
print "FIN\r"

i never "found" !!!

Why ?

Re: Import Word document in DOORS, using style
Peter_Albert - Wed Oct 21 08:12:16 EDT 2009

PDU - Wed Oct 21 07:59:01 EDT 2009
Thanks,

but just a "little" problem, i do not find tables !!!

i write this check code :

Module CeModule = current
Object ObjetEnCours

for ObjetEnCours in CeModule do
{
print ObjetEnCours."Absolute Number" " --> " (table ObjetEnCours) "\n"
if (table ObjetEnCours)
{
print "found\r"
continue
}

}
print "FIN\r"

i never "found" !!!

Why ?

There are a couple of slightly different 'for object in ... module' loops available in DXL. The DXL manual reads "for object in module ... Assigns the variable o to be each successive object in module in depth first order, including the cells only of any DOORS native tables."

Cells only, i.e. no table objects, no row objects.

It is good practice to always use the 'for object in entire module' loop and then to 'continue' for the objects you want to skip. Your example then looks like

Module CeModule = current
Object ObjetEnCours
 
for ObjetEnCours in entire CeModule do
{
  if (isDeleted ObjetEnCours){continue}
  //print ObjetEnCours."Absolute Number" " --> " (table ObjetEnCours) "\n"
  if (table ObjetEnCours)
  {
    print "found\n"
    continue
  }
}
print "FIN\n"

 


(If you put {code} before and after your DXL example, it looks better, keeps indentation, etc. in the post)

Regards,

Peter

 

Re: Import Word document in DOORS, using style
ePiallat - Wed Oct 21 10:15:06 EDT 2009

Peter_Albert - Wed Oct 21 08:12:16 EDT 2009

There are a couple of slightly different 'for object in ... module' loops available in DXL. The DXL manual reads "for object in module ... Assigns the variable o to be each successive object in module in depth first order, including the cells only of any DOORS native tables."

Cells only, i.e. no table objects, no row objects.

It is good practice to always use the 'for object in entire module' loop and then to 'continue' for the objects you want to skip. Your example then looks like

Module CeModule = current
Object ObjetEnCours
 
for ObjetEnCours in entire CeModule do
{
  if (isDeleted ObjetEnCours){continue}
  //print ObjetEnCours."Absolute Number" " --> " (table ObjetEnCours) "\n"
  if (table ObjetEnCours)
  {
    print "found\n"
    continue
  }
}
print "FIN\n"

 


(If you put {code} before and after your DXL example, it looks better, keeps indentation, etc. in the post)

Regards,

Peter

 

Yes ! As a reminder :

Considering the following variables:
Object o
Object othero = current Object
Module m      = current Module
/* Looping through display set: loop through all objects */
for o in m do {} //including cells
for o in document m do {} //including table headers
for o in all m do {} //including table headers & cells
 
/* Looping through every object: */
for o in entire m do {} //including undisplayed & deletions
 
/* Looping through objects at same level: */
for o in top m do {}  //1st level objects only
for o in othero do {} //childs of the object

 


But on second thought in your specific case, using a single loop is dangerous: if you delete or create new objects within the "for Object in ..." loop, you take the risk to invalidate the iterator object.
It could be avoided:

 

 

  • either by replacing the "for ... do" loop by a "while" loop, and navigating with "next Object" and "previous Object". In this case, you need to detect cells instead of table, with the "bool cell (Object)" function. (Table object is oTable = parent parent oCell)
  • or by using two loops: a first loop will detect tables and populate a skip list with objects, the second one will loop through the skip list and perform creations and deletions of objects.

(btw, I just realized we are neighbors.)

 

Re: Import Word document in DOORS, using style
PDU - Thu Oct 22 10:51:34 EDT 2009

ePiallat - Wed Oct 21 10:15:06 EDT 2009

Yes ! As a reminder :

Considering the following variables:
Object o
Object othero = current Object
Module m      = current Module
/* Looping through display set: loop through all objects */
for o in m do {} //including cells
for o in document m do {} //including table headers
for o in all m do {} //including table headers & cells
 
/* Looping through every object: */
for o in entire m do {} //including undisplayed & deletions
 
/* Looping through objects at same level: */
for o in top m do {}  //1st level objects only
for o in othero do {} //childs of the object

 


But on second thought in your specific case, using a single loop is dangerous: if you delete or create new objects within the "for Object in ..." loop, you take the risk to invalidate the iterator object.
It could be avoided:

 

 

  • either by replacing the "for ... do" loop by a "while" loop, and navigating with "next Object" and "previous Object". In this case, you need to detect cells instead of table, with the "bool cell (Object)" function. (Table object is oTable = parent parent oCell)
  • or by using two loops: a first loop will detect tables and populate a skip list with objects, the second one will loop through the skip list and perform creations and deletions of objects.

(btw, I just realized we are neighbors.)

 

Thanks very much Eric and Peter.

I send you (and for others users) my script.
It works fine.

(sorry, dialog box are in french)

Regards
Pierre
Attachments

attachment_14307813_ExtractRequirementFromTables.dxl

Re: Import Word document in DOORS, using style
SystemAdmin - Fri Oct 23 08:57:50 EDT 2009

PDU - Thu Oct 22 10:51:34 EDT 2009
Thanks very much Eric and Peter.

I send you (and for others users) my script.
It works fine.

(sorry, dialog box are in french)

Regards
Pierre

Hi Pierre,

Thanks, this script looks like it could be quite useful for us. Unfortunately I guess most of the users of the forum - like me - don´t speak French well enough to really use the script (but working on it since French is a great language).

Do you have an easy way to provide it in English..... sorry for my greedy immodesty...;-)

peter

Re: Import Word document in DOORS, using style
PDU - Fri Oct 23 10:48:34 EDT 2009

SystemAdmin - Fri Oct 23 08:57:50 EDT 2009
Hi Pierre,

Thanks, this script looks like it could be quite useful for us. Unfortunately I guess most of the users of the forum - like me - don´t speak French well enough to really use the script (but working on it since French is a great language).

Do you have an easy way to provide it in English..... sorry for my greedy immodesty...;-)

peter

Hi Peter,

here same script in englsh (not good english, but i hope you can understand and improve)

Regards

Pierre
Attachments

attachment_14308210_ExtractRequirementFromTables.dxl

Re: Import Word document in DOORS, using style
SystemAdmin - Sun Oct 25 05:49:07 EDT 2009

PDU - Fri Oct 23 10:48:34 EDT 2009
Hi Peter,

here same script in englsh (not good english, but i hope you can understand and improve)

Regards

Pierre

Very much appreciated, Pierre.

peter

Re: Import Word document in DOORS, using style
PDU - Mon Oct 26 05:04:48 EDT 2009

SystemAdmin - Sun Oct 25 05:49:07 EDT 2009
Very much appreciated, Pierre.

peter

Hi,

as i receive Word document with requirements in tables, but without Styles, a make an other script, using only cells positions.

in attached file

Regards
Attachments

attachment_14308636_ExtractRequirementFromTablesByPosition.dxl